package tech.heptagram.staff.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

import tech.heptagram.staff.model.ProcessRecord;

@Mapper
public interface ProcessRecordMapper {
    /**
     * 插入审批记录
     *
     * @param processRecord
     * @return
     */
    int insert(ProcessRecord processRecord);

    /**
     * 更新审批状态到开始
     *
     * @param bpmsProcessId 钉钉审批实体ID
     * @return
     */
    int updateStateToStart(@Param("bpmsProcessId") String bpmsProcessId);

    /**
     * 更新状态到撤销
     *
     * @param bpmsProcessId
     * @return
     */
    int updateStateToTerminate(@Param("bpmsProcessId") String bpmsProcessId);

    /**
     * 更新审批状态到结束
     *
     * @param bpmsProcessId     钉钉审批实体ID
     * @param applicationResult 结果
     * @return
     */
    int updateStateToFinish(@Param("bpmsProcessId") String bpmsProcessId, @Param("applicationResult") Integer applicationResult);

    /**
     * 更新审批拒绝原因
     *
     * @param bpmsProcessId 钉钉审批实体ID
     * @param rejectMessage 拒绝原因
     * @return
     */
    int updateRejectMessage(@Param("bpmsProcessId") String bpmsProcessId, @Param("rejectMessage") String rejectMessage);

    /**
     * 根据指定条件查询记录信息，无视删除字段
     *
     * @param bpmsProcessId
     * @return
     */
    ProcessRecord selectByBpmsProcessId(@Param("bpmsProcessId") String bpmsProcessId);


    List<ProcessRecord> selectStaffProcessByTypeAndState(@Param("applicationCode") String applicationCode,
                                                         @Param("processType") Integer processType,
                                                         @Param("applicationState") Integer applicationState);

    List<ProcessRecord> selectStaffProcessByTypeAndState2(ProcessRecord query);
}
